import request from '@/utils/request'

/*
攻略帖
*/
// 获取攻略贴信息
export const getPostInfoService = (limit) => request.get(`/postLimit?limit=${limit}`)

// 通过id获取攻略帖
export const getPostByIdService = (id) => request.get(`/postById?id=${id}`)

// 获取攻略贴分类
export const getPostCategoryService = () => request.get(`/postcategory`)

// 按分类获取攻略贴
export const getPostByCategoryService = (id) => request.get(`/post/category?category_id=${id}`)

// 搜索攻略贴
export const searchPostService = (keyword) => request.get(`/post/search?q=${keyword}`)

// 获取攻略帖评论
export const getPostCommentService = (id) => request.get(`/post/comments?post_id= ${id}`)

// 新增攻略贴评论
export const addPostCommentService = (data) => request.post('/post/commentInsert', data)

// 发布攻略帖
export const addPostService = (data) => request.post('/post/release', data)

/*
讨论贴
*/
// 获取讨论贴信息
export const getTopicsInfoService = (limit) => request.get(`/topics?limit=${limit}`)

// 获取讨论贴分类
export const getTopicsCategoryService = () => request.get(`/topicscategory`)

// 按分类获取讨论贴
export const getTopicsByCategoryService = (id) => request.get(`/post/category?category_id=${id}`)

// 发布讨论贴
export const postTopicsService = (data) => request.post(`/topics/release`, data)

/*
用户发帖数据
*/
// 获取用户攻略帖
export const getUserPostsService = (id) => request.get(`/user/posts?user_id=${id}`)

// 获取用户讨论贴
export const getUserTopicsService = (id) => request.get(`/user/topics?user_id=${id}`)

// 删除用户攻略帖
export const deleteUserPostService = (data) => request.delete('/user/postdelete', { data });

// 删除用户讨论帖
export const deleteUserTopicService = (data) => request.delete('/user/topicdelete', { data });